package top.lossingdawn.http.request.demo.rest;

import com.alibaba.fastjson.JSON;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;
import top.lossingdawn.http.request.demo.entity.RequestParams;
import top.lossingdawn.http.request.demo.entity.RequestScopeDTO;

import javax.websocket.server.PathParam;

/**
 * @author jiangyj
 * @version 1.0
 * @create 2021-06-29 15:48
 **/
@Api(tags = "GET接口示例")
@RestController
@RequestMapping("/get")
public class GetController {

    /*****path*****/
    @GetMapping("path/{id}")
    public String path(String id, String name) {
        return "path：" + id;
    }


    @GetMapping("path2/{id}")
    public String path2(@PathParam("id") String id, String name) {
        return "path2：" + id;
    }

    @GetMapping("path3/{id}")
    public String path3(RequestParams requestParams) {
        return "path3：" + JSON.toJSONString(requestParams);
    }


    /*****RequestParam*****/
    @GetMapping("params")
    public String params(@RequestParam String id) {
        return "params：" + id;
    }


    /*****RequestPart*****/
    @GetMapping("requestPart")
    public String requestPart(@RequestPart String id) {
        return "params：" + id;
    }


    /*****RequestHeader*****/
    @GetMapping("RequestHeader")
    public String requestHeader(@RequestHeader String id) {
        return "params：" + id;
    }


    /*****RequestAttribute*****/
    @GetMapping("RequestAttribute")
    public String requestAttribute(@RequestAttribute String id) {
        return "params：" + id;
    }

    @GetMapping("RequestScope")
    public String requestScope(RequestScopeDTO requestScopeDTO) {
        return "params：" + JSON.toJSONString(requestScopeDTO);
    }


    /*****RequestBody*****/
    @GetMapping("RequestBody")
    public String requestBody(@RequestBody String id) {
        return "params：" + id;
    }


}
